package com.vrv.vap.baseline.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@ConfigurationProperties(prefix = "excel")
public class ExcelTemplateConfig {
    private List<TemplateProperties> templates;

    public List<TemplateProperties> getTemplates() {
        return templates;
    }

    public void setTemplates(List<TemplateProperties> templates) {
        this.templates = templates;
    }

    public TemplateProperties getTemplateByKey(String key) {
        return templates.stream()
                .filter(template -> template.getKey().equals(key))
                .findFirst()
                .orElseThrow(() -> new RuntimeException("Template not found for key: " + key));
    }

    public static class TemplateProperties {
        private String key;
        private int maxCellLength;
        private String fileName;
        private String sheetName;

        public String getKey() {
            return key;
        }

        public void setKey(String key) {
            this.key = key;
        }

        public int getMaxCellLength() {
            return maxCellLength;
        }

        public void setMaxCellLength(int maxCellLength) {
            this.maxCellLength = maxCellLength;
        }

        public String getFileName() {
            return fileName;
        }

        public void setFileName(String fileName) {
            this.fileName = fileName;
        }

        public String getSheetName() {
            return sheetName;
        }

        public void setSheetName(String sheetName) {
            this.sheetName = sheetName;
        }
    }
}